<script type="text/javascript">
	/*$(document).ready(function() {
		now = new Date();
		$('#Job_received_time').datepicker({
			alert('asa');
			showAnim   => 'fold',
			showOn     =>'button',
			buttonText =>Yii::t('ui','Select form calendar'),
			buttonImage=>Yii::app()->request->baseUrl.'/images/calendar.png',
			buttonImageOnly=>true,
			dateFormat: now.getHours() + ":" + now.getMinutes() + " dd-mm-yy"
		});
		$('#Job_finished_time').datepicker({dateFormat: "dd-mm-yy " + now.getHours() + ":" + now.getMinutes() + ":00"});
	});
	*/
	$(document).ready(function() {		
            
            $('#Job_job_group_id').click(function(){
			now = new Date();
			var month = now.getMonth() + 1;
			var day = now.getDate();
			var hours =  now.getHours();
			var minutes = now.getMinutes();
			if(day < 10)
			{
				day = '0' + day;
			}
			if(month < 10)
			{
				month = '0' + month;
			}
			if(hours < 10)
			{
				hours = '0' + hours;
			}
			if(minutes < 10)
			{
				minutes = '0' + minutes;
			}
			dateNow = hours + ":" + minutes + " " + day + "-" + month + "-" + now.getFullYear();
			document.getElementById('Job_received_time').value = dateNow;		
            });
		$('#Job_solution').blur(function(){
			now = new Date();
			var month = now.getMonth() + 1;
			var day = now.getDate();
			var hours =  now.getHours();
			var minutes = now.getMinutes();
			if(day < 10)
			{
				day = '0' + day;
			}
			if(month < 10)
			{
				month = '0' + month;
			}
			if(hours < 10)
			{
				hours = '0' + hours;
			}
			if(minutes < 10)
			{
				minutes = '0' + minutes;
			}
			dateNow = hours + ":" + minutes + " " + day + "-" + month + "-" + now.getFullYear();
			document.getElementById('Job_finished_time').value = dateNow;
		});
	});
	function getReceivedTime()
	{
		now = new Date();
		alert(now);
		dateNow = now.getHours() + ":" + now.getMinutes() + " " + now.getDay() + "-" + now.getMonth() + "-" + now.getFullYear();
		alert(now.getDay());
		document.getElementById('Job_received_time').value = dateNow;
	}
	function getFinishedTime()
	{
		now = new Date();
		var month = now.getMonth() + 1;
		dateNow = now.getHours() + ":" + now.getMinutes() + " " + now.getDate() + "-" + month + "-" + now.getFullYear();
		document.getElementById('Job_finished_time').value = dateNow;
	}
	function isDate(dateStr) 
	{
		var re = /^(\d{1,2})(\/|-)(\w{1,3})(\/|-)(\d{2,4})( )(\d{1,2})(:)(\d{1,2})(:)(\d{1,2})$/;
		if (re.test(dateStr)) 
			return true;
		return false;
	}
</script>
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'job-form',
	//'enableAjaxValidation'=>true,
	)); 
?>

	<p class="note">Những trường có dấu <span class="required">*</span> bắt buộc phải điền vào.</p>

	<?php echo $form->errorSummary($model); ?>

	<div class="row">
		<?php echo $form->labelEx($model,'department'); ?>
		<?php echo $form->textField($model,'department',array('size'=>60,'maxlength'=>256)); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'received_time'); ?>
		<?php //echo $form->textField($model,'received_time'); ?>
		<?php
			$form->widget('zii.widgets.jui.CJuiDatePicker', array(
					'name'=>CHtml::activeName($model,'received_time'),   
					'model'=>$model,
					'attribute'=>'received_time',
					'options' => array(
						'onSelect'=>"js:function(selectedDate){
							var now = new Date();
							var hours =  now.getHours();
							var minutes = now.getMinutes();
							if(hours < 10)
							{
								hours = '0' + hours;
							}
							if(minutes < 10)
							{
								minutes = '0' + minutes;
							}
							var formattedDate =  hours + ':' +  minutes + ' ' + selectedDate;
							$(this).val(formattedDate);							
						}",
					),

				));
			?>
		
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'finished_time'); ?>
		<?php //echo $form->textField($model,'finished_time'); ?>
		<?php
			$form->widget('zii.widgets.jui.CJuiDatePicker', array(
					'name'=>CHtml::activeName($model,'finished_time'),   
					'model'=>$model,
					'attribute'=>'finished_time',					
					'options' => array(
						'onSelect'=>"js:function(selectedDate){
							var now = new Date();
							var hours =  now.getHours();
							var minutes = now.getMinutes();
							if(hours < 10)
							{
								hours = '0' + hours;
							}
							if(minutes < 10)
							{
								minutes = '0' + minutes;
							}
							var formattedDate =  now.getHours() + ':' + now.getMinutes() + ' ' + selectedDate;
							$(this).val(formattedDate);							
						}",
					),

				));
			?>	
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'job_group_id'); ?>
		<?php echo $form->dropDownList($model,'job_group_id', CHtml::listData(JobGroup::model()->findAll(), 'id', 'name')); ?>
		<?php echo $form->error($model,'job_group_id'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'detail'); ?>
		<?php echo $form->textArea($model,'detail',array('rows'=>6, 'cols'=>50)); ?>
		
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'solution'); ?>
		<?php echo $form->textArea($model,'solution',array('rows'=>6, 'cols'=>50 )); ?>

	</div>
	
	<div class="row">
		<?php echo $form->labelEx($model,'job_type_id'); ?>
		<?php echo $form->dropDownList($model,'job_type_id', CHtml::listData(JobType::model()->findAll(), 'id', 'name')); ?>
	</div>
	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Lưu' : 'Cập nhật'); ?>
	</div>
<?php $this->endWidget(); ?>

</div><!-- form -->